home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 2 / adb / a-strunb < prev    next >
Text File  |  1996-02-12  |  21KB  |  828 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . U N B O U N D E D                 --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.16 $                             --
  10. --                                                                          --
  11. --   Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc.  --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Ada.Strings.Fixed;
  37. with Ada.Strings.Search;
  38. with Ada.Unchecked_Deallocation;
  39.  
  40. package body Ada.Strings.Unbounded is
  41.  
  42.    use Ada.Finalization;
  43.  
  44.    ----------------
  45.    -- Initialize --
  46.    ----------------
  47.  
  48.    procedure Initialize (Object : in out Unbounded_String) is
  49.    begin
  50.       Object.Reference := Null_Unbounded_String.Reference;
  51.    end Initialize;
  52.  
  53.    ------------
  54.    -- Adjust --
  55.    ------------
  56.  
  57.    procedure Adjust (Object : in out Unbounded_String) is
  58.    begin
  59.       Object.Reference := new String'(Object.Reference.all);
  60.    end Adjust;
  61.  
  62.    ----------
  63.    -- Free --
  64.    ----------
  65.  
  66.    procedure Free (X : in out String_Access) is
  67.       procedure Deallocate is
  68.          new Ada.Unchecked_Deallocation (String, String_Access);
  69.    begin
  70.       Deallocate (X);
  71.    end Free;
  72.  
  73.    --------------
  74.    -- Finalize --
  75.    --------------
  76.  
  77.    procedure Finalize   (Object : in out Unbounded_String) is
  78.    begin
  79.       if Object.Reference /= Null_Unbounded_String.Reference then
  80.          Free (Object.Reference);
  81.       end if;
  82.    end Finalize;
  83.  
  84.    ---------
  85.    -- "=" --
  86.    ---------
  87.  
  88.    function "=" (Left, Right : in Unbounded_String) return Boolean is
  89.    begin
  90.       return Left.Reference.all = Right.Reference.all;
  91.    end "=";
  92.  
  93.    function "="
  94.      (Left  : in Unbounded_String;
  95.       Right : in String)
  96.       return  Boolean
  97.    is
  98.    begin
  99.       return Left.Reference.all = Right;
  100.    end "=";
  101.  
  102.    function "="
  103.      (Left  : in String;
  104.       Right : in Unbounded_String)
  105.       return  Boolean
  106.    is
  107.    begin
  108.       return Left = Right.Reference.all;
  109.    end "=";
  110.  
  111.    ---------
  112.    -- "<" --
  113.    ---------
  114.  
  115.    function "<" (Left, Right : in Unbounded_String) return Boolean is
  116.    begin
  117.       return Left.Reference.all < Right.Reference.all;
  118.    end "<";
  119.  
  120.    function "<"
  121.      (Left  : in Unbounded_String;
  122.       Right : in String)
  123.       return  Boolean
  124.    is
  125.    begin
  126.       return Left.Reference.all < Right;
  127.    end "<";
  128.  
  129.    function "<"
  130.      (Left  : in String;
  131.       Right : in Unbounded_String)
  132.       return  Boolean
  133.    is
  134.    begin
  135.       return Left < Right.Reference.all;
  136.    end "<";
  137.  
  138.    ----------
  139.    -- "<=" --
  140.    ----------
  141.  
  142.    function "<=" (Left, Right : in Unbounded_String) return Boolean is
  143.    begin
  144.       return Left.Reference.all <= Right.Reference.all;
  145.    end "<=";
  146.  
  147.    function "<="
  148.      (Left  : in Unbounded_String;
  149.       Right : in String)
  150.       return  Boolean
  151.    is
  152.    begin
  153.       return Left.Reference.all <= Right;
  154.    end "<=";
  155.  
  156.    function "<="
  157.      (Left  : in String;
  158.       Right : in Unbounded_String)
  159.       return  Boolean
  160.    is
  161.    begin
  162.       return Left <= Right.Reference.all;
  163.    end "<=";
  164.  
  165.    ---------
  166.    -- ">" --
  167.    ---------
  168.  
  169.    function ">"  (Left, Right : in Unbounded_String) return Boolean is
  170.    begin
  171.       return Left.Reference.all > Right.Reference.all;
  172.    end ">";
  173.  
  174.    function ">"
  175.      (Left  : in Unbounded_String;
  176.       Right : in String)
  177.       return  Boolean
  178.    is
  179.    begin
  180.       return Left.Reference.all > Right;
  181.    end ">";
  182.  
  183.    function ">"
  184.      (Left  : in String;
  185.       Right : in Unbounded_String)
  186.       return  Boolean
  187.    is
  188.    begin
  189.       return Left > Right.Reference.all;
  190.    end ">";
  191.  
  192.    ----------
  193.    -- ">=" --
  194.    ----------
  195.  
  196.    function ">=" (Left, Right : in Unbounded_String) return Boolean is
  197.    begin
  198.       return Left.Reference.all >= Right.Reference.all;
  199.    end ">=";
  200.  
  201.    function ">="
  202.      (Left  : in Unbounded_String;
  203.       Right : in String)
  204.       return  Boolean
  205.    is
  206.    begin
  207.       return Left.Reference.all >= Right;
  208.    end ">=";
  209.  
  210.    function ">="
  211.      (Left  : in String;
  212.       Right : in Unbounded_String)
  213.       return  Boolean
  214.    is
  215.    begin
  216.       return Left >= Right.Reference.all;
  217.    end ">=";
  218.  
  219.    ---------
  220.    -- "*" --
  221.    ---------
  222.  
  223.    function "*"
  224.      (Left  : Natural;
  225.       Right : Character)
  226.       return  Unbounded_String
  227.    is
  228.       Result : Unbounded_String;
  229.  
  230.    begin
  231.       Result.Reference := new String (1 .. Left);
  232.       for J in Result.Reference'Range loop
  233.          Result.Reference (J) := Right;
  234.       end loop;
  235.  
  236.       return Result;
  237.    end "*";
  238.  
  239.    function "*"
  240.      (Left  : Natural;
  241.       Right : String)
  242.      return   Unbounded_String
  243.    is
  244.       Len    : constant Integer := Right'Length;
  245.       Result : Unbounded_String;
  246.  
  247.    begin
  248.       Result.Reference := new String (1 .. Left * Len);
  249.       for J in 1 .. Left loop
  250.          Result.Reference.all (Len * J - Len + 1 .. Len * J) := Right;
  251.       end loop;
  252.  
  253.       return Result;
  254.    end "*";
  255.  
  256.    function "*"
  257.      (Left  : Natural;
  258.       Right : Unbounded_String)
  259.       return  Unbounded_String
  260.    is
  261.       Len    : constant Integer := Right.Reference.all'Length;
  262.       Result : Unbounded_String;
  263.  
  264.    begin
  265.       Result.Reference := new String (1 .. Left * Len);
  266.       for I in 1 .. Left loop
  267.          Result.Reference.all (Len * I - Len + 1 .. Len * I) :=
  268.            Right.Reference.all;
  269.       end loop;
  270.  
  271.       return Result;
  272.    end "*";
  273.  
  274.    ---------
  275.    -- "&" --
  276.    ---------
  277.  
  278.    function "&" (Left, Right : Unbounded_String) return Unbounded_String is
  279.       L_Length : constant Integer := Left.Reference.all'Length;
  280.       R_Length : constant Integer := Right.Reference.all'Length;
  281.       Length   : constant Integer :=  L_Length + R_Length;
  282.       Result   : Unbounded_String;
  283.  
  284.    begin
  285.       Result.Reference := new String (1 .. Length);
  286.       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
  287.       Result.Reference.all (L_Length + 1 .. Length) := Right.Reference.all;
  288.       return Result;
  289.    end "&";
  290.  
  291.    function "&"
  292.      (Left  : Unbounded_String;
  293.       Right : String)
  294.       return  Unbounded_String
  295.    is
  296.       L_Length : constant Integer := Left.Reference.all'Length;
  297.       Length   : constant Integer := L_Length +  Right'Length;
  298.       Result   : Unbounded_String;
  299.  
  300.    begin
  301.       Result.Reference := new String (1 .. Length);
  302.       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
  303.       Result.Reference.all (L_Length + 1 .. Length) := Right;
  304.       return Result;
  305.    end "&";
  306.  
  307.    function "&"
  308.      (Left  : String;
  309.       Right : Unbounded_String)
  310.       return  Unbounded_String
  311.    is
  312.       R_Length : constant Integer := Right.Reference.all'Length;
  313.       Length   : constant Integer := Left'Length + R_Length;
  314.       Result   : Unbounded_String;
  315.  
  316.    begin
  317.       Result.Reference := new String (1 .. Length);
  318.       Result.Reference.all (1 .. Left'Length)          := Left;
  319.       Result.Reference.all (Left'Length + 1 .. Length) := Right.Reference.all;
  320.       return Result;
  321.    end "&";
  322.  
  323.    function "&"
  324.      (Left  : Unbounded_String;
  325.       Right : Character)
  326.       return  Unbounded_String
  327.    is
  328.       Length : constant Integer := Left.Reference.all'Length + 1;
  329.       Result : Unbounded_String;
  330.  
  331.    begin
  332.       Result.Reference := new String (1 .. Length);
  333.       Result.Reference.all (1 .. Length - 1) := Left.Reference.all;
  334.       Result.Reference.all (Length)          := Right;
  335.       return Result;
  336.    end "&";
  337.  
  338.    function "&"
  339.      (Left  : Character;
  340.       Right : Unbounded_String)
  341.       return  Unbounded_String
  342.    is
  343.       Length : constant Integer := Right.Reference.all'Length + 1;
  344.       Result : Unbounded_String;
  345.  
  346.    begin
  347.       Result.Reference := new String (1 .. Length);
  348.       Result.Reference.all (1)           := Left;
  349.       Result.Reference.all (2 .. Length) := Right.Reference.all;
  350.       return Result;
  351.    end "&";
  352.  
  353.    -----------
  354.    -- Count --
  355.    -----------
  356.  
  357.    function Count
  358.      (Source   : Unbounded_String;
  359.       Pattern  : String;
  360.       Mapping  : Maps.Character_Mapping := Maps.Identity)
  361.       return     Natural
  362.    is
  363.    begin
  364.       return Search.Count (Source.Reference.all, Pattern, Mapping);
  365.    end Count;
  366.  
  367.    function Count
  368.      (Source   : in Unbounded_String;
  369.       Pattern  : in String;
  370.       Mapping  : in Maps.Character_Mapping_Function)
  371.       return     Natural
  372.    is
  373.    begin
  374.       return Search.Count (Source.Reference.all, Pattern, Mapping);
  375.    end Count;
  376.  
  377.    function Count
  378.      (Source   : Unbounded_String;
  379.       Set      : Maps.Character_Set)
  380.       return     Natural
  381.    is
  382.    begin
  383.       return Search.Count (Source.Reference.all, Set);
  384.    end Count;
  385.  
  386.    ------------
  387.    -- Delete --
  388.    ------------
  389.  
  390.    function Delete
  391.      (Source  : Unbounded_String;
  392.       From    : Positive;
  393.       Through : Natural)
  394.       return    Unbounded_String
  395.    is
  396.    begin
  397.       return
  398.         To_Unbounded_String
  399.           (Fixed.Delete (Source.Reference.all, From, Through));
  400.    end Delete;
  401.  
  402.    procedure Delete
  403.      (Source  : in out Unbounded_String;
  404.       From    : in Positive;
  405.       Through : in Natural)
  406.    is
  407.  
  408.    begin
  409.       Source := To_Unbounded_String
  410.         (Fixed.Delete (Source.Reference.all, From, Through));
  411.    end Delete;
  412.  
  413.    -------------
  414.    -- Element --
  415.    -------------
  416.  
  417.    function Element
  418.      (Source : Unbounded_String;
  419.       Index  : Positive)
  420.       return   Character
  421.    is
  422.    begin
  423.       if Index <= Source.Reference.all'Last then
  424.          return Source.Reference.all (Index);
  425.       else
  426.          raise Strings.Index_Error;
  427.       end if;
  428.    end Element;
  429.  
  430.    ----------------
  431.    -- Find_Token --
  432.    ----------------
  433.  
  434.    procedure Find_Token
  435.      (Source : Unbounded_String;
  436.       Set    : Maps.Character_Set;
  437.       Test   : Strings.Membership;
  438.       First  : out Positive;
  439.       Last   : out Natural)
  440.    is
  441.    begin
  442.       Search.Find_Token (Source.Reference.all, Set, Test, First, Last);
  443.    end Find_Token;
  444.  
  445.    ----------
  446.    -- Head --
  447.    ----------
  448.  
  449.    function Head
  450.      (Source : Unbounded_String;
  451.       Count  : Natural;
  452.       Pad    : Character := Space)
  453.       return   Unbounded_String
  454.    is
  455.    begin
  456.       return
  457.         To_Unbounded_String (Fixed.Head (Source.Reference.all, Count, Pad));
  458.    end Head;
  459.  
  460.    procedure Head
  461.      (Source : in out Unbounded_String;
  462.       Count  : in Natural;
  463.       Pad    : in Character := Space)
  464.    is
  465.    begin
  466.       Source := To_Unbounded_String
  467.         (Fixed.Head (Source.Reference.all, Count, Pad));
  468.    end Head;
  469.  
  470.    -----------
  471.    -- Index --
  472.    -----------
  473.  
  474.    function Index
  475.      (Source   : Unbounded_String;
  476.       Pattern  : String;
  477.       Going    : Strings.Direction := Strings.Forward;
  478.       Mapping  : Maps.Character_Mapping := Maps.Identity)
  479.       return     Natural
  480.    is
  481.    begin
  482.       return Search.Index (Source.Reference.all, Pattern, Going, Mapping);
  483.    end Index;
  484.  
  485.    function Index
  486.      (Source   : in Unbounded_String;
  487.       Pattern  : in String;
  488.       Going    : in Direction := Forward;
  489.       Mapping  : in Maps.Character_Mapping_Function)
  490.       return Natural
  491.    is
  492.    begin
  493.       return Search.Index (Source.Reference.all, Pattern, Going, Mapping);
  494.    end Index;
  495.  
  496.    function Index
  497.      (Source : Unbounded_String;
  498.       Set    : Maps.Character_Set;
  499.       Test   : Strings.Membership := Strings.Inside;
  500.       Going  : Strings.Direction  := Strings.Forward)
  501.       return   Natural
  502.    is
  503.    begin
  504.       return Search.Index (Source.Reference.all, Set, Test, Going);
  505.    end Index;
  506.  
  507.    function Index_Non_Blank
  508.      (Source : Unbounded_String;
  509.       Going  : Strings.Direction := Strings.Forward)
  510.       return   Natural
  511.    is
  512.    begin
  513.       return Search.Index_Non_Blank (Source.Reference.all, Going);
  514.    end Index_Non_Blank;
  515.  
  516.    ------------
  517.    -- Insert --
  518.    ------------
  519.  
  520.    function Insert
  521.      (Source   : Unbounded_String;
  522.       Before   : Positive;
  523.       New_Item : String)
  524.       return     Unbounded_String
  525.    is
  526.    begin
  527.       return
  528.         To_Unbounded_String
  529.           (Fixed.Insert (Source.Reference.all, Before, New_Item));
  530.    end Insert;
  531.  
  532.    procedure Insert
  533.      (Source   : in out Unbounded_String;
  534.       Before   : in Positive;
  535.       New_Item : in String)
  536.    is
  537.    begin
  538.       Source := To_Unbounded_String
  539.         (Fixed.Insert (Source.Reference.all, Before, New_Item));
  540.    end Insert;
  541.  
  542.    ------------
  543.    -- Length --
  544.    ------------
  545.  
  546.    function Length (Source : Unbounded_String) return Natural is
  547.    begin
  548.       return Source.Reference.all'Length;
  549.    end Length;
  550.  
  551.    ---------------
  552.    -- Overwrite --
  553.    ---------------
  554.  
  555.    function Overwrite
  556.      (Source    : Unbounded_String;
  557.       Position  : Positive;
  558.       New_Item  : String)
  559.       return      Unbounded_String is
  560.  
  561.    begin
  562.       return To_Unbounded_String
  563.         (Fixed.Overwrite (Source.Reference.all, Position, New_Item));
  564.    end Overwrite;
  565.  
  566.    procedure Overwrite
  567.      (Source    : in out Unbounded_String;
  568.       Position  : in Positive;
  569.       New_Item  : in String)
  570.    is
  571.    begin
  572.       Source := To_Unbounded_String
  573.         (Fixed.Overwrite (Source.Reference.all, Position, New_Item));
  574.    end Overwrite;
  575.  
  576.    ---------------------
  577.    -- Replace_Element --
  578.    ---------------------
  579.  
  580.    procedure Replace_Element
  581.      (Source : in out Unbounded_String;
  582.       Index  : Positive;
  583.       By     : Character)
  584.    is
  585.    begin
  586.       if Index <= Source.Reference.all'Last then
  587.          Source.Reference.all (Index) := By;
  588.       else
  589.          raise Strings.Index_Error;
  590.       end if;
  591.    end Replace_Element;
  592.  
  593.    -------------------
  594.    -- Replace_Slice --
  595.    -------------------
  596.  
  597.    function Replace_Slice
  598.      (Source   : Unbounded_String;
  599.       Low      : Positive;
  600.       High     : Natural;
  601.       By       : String)
  602.       return     Unbounded_String
  603.    is
  604.    begin
  605.       return
  606.         To_Unbounded_String
  607.           (Fixed.Replace_Slice (Source.Reference.all, Low, High, By));
  608.    end Replace_Slice;
  609.  
  610.    procedure Replace_Slice
  611.      (Source   : in out Unbounded_String;
  612.       Low      : in Positive;
  613.       High     : in Natural;
  614.       By       : in String)
  615.    is
  616.    begin
  617.       Source := To_Unbounded_String
  618.         (Fixed.Replace_Slice (Source.Reference.all, Low, High, By));
  619.    end Replace_Slice;
  620.  
  621.    -----------
  622.    -- Slice --
  623.    -----------
  624.  
  625.    function Slice
  626.      (Source : Unbounded_String;
  627.       Low    : Positive;
  628.       High   : Natural)
  629.       return   String
  630.    is
  631.       Result : String (1 .. High - Low + 1);
  632.  
  633.    begin
  634.       Result := Source.Reference.all (Low .. High);
  635.       return Result;
  636.    end Slice;
  637.  
  638.    ----------
  639.    -- Tail --
  640.    ----------
  641.  
  642.    function Tail
  643.      (Source : Unbounded_String;
  644.       Count  : Natural;
  645.       Pad    : Character := Space)
  646.       return   Unbounded_String is
  647.  
  648.    begin
  649.       return
  650.         To_Unbounded_String (Fixed.Tail (Source.Reference.all, Count, Pad));
  651.    end Tail;
  652.  
  653.    procedure Tail
  654.      (Source : in out Unbounded_String;
  655.       Count  : in Natural;
  656.       Pad    : in Character := Space)
  657.    is
  658.       Temp : String_Access := Source.Reference;
  659.  
  660.    begin
  661.       Source := To_Unbounded_String
  662.         (Fixed.Tail (Temp.all, Count, Pad));
  663.       Free (Temp);
  664.    end Tail;
  665.  
  666.    ---------------
  667.    -- To_String --
  668.    ---------------
  669.  
  670.    function To_String (Source : Unbounded_String) return String is
  671.    begin
  672.       return Source.Reference.all;
  673.    end To_String;
  674.  
  675.    -------------------------
  676.    -- To_Unbounded_String --
  677.    -------------------------
  678.  
  679.    function To_Unbounded_String (Source : String) return Unbounded_String is
  680.       Result : Unbounded_String;
  681.  
  682.    begin
  683.       Result.Reference := new String'(Source);
  684.       return Result;
  685.    end To_Unbounded_String;
  686.  
  687.    function To_Unbounded_String (Length : in Natural)
  688.       return Unbounded_String
  689.    is
  690.       Result : Unbounded_String;
  691.  
  692.    begin
  693.       Result.Reference := new String (1 .. Length);
  694.       return Result;
  695.    end To_Unbounded_String;
  696.  
  697.    ------------
  698.    -- Append --
  699.    ------------
  700.  
  701.    procedure Append
  702.      (Source   : in out Unbounded_String;
  703.       New_Item : in Unbounded_String)
  704.    is
  705.       S_Length : constant Integer := Source.Reference.all'Length;
  706.       Length   : constant Integer := S_Length + New_Item.Reference.all'Length;
  707.       Tmp      : String_Access;
  708.  
  709.    begin
  710.       Tmp := new String (1 .. Length);
  711.       Tmp (1 .. S_Length) := Source.Reference.all;
  712.       Tmp (S_Length + 1 .. Length) := New_Item.Reference.all;
  713.       Source := (Controlled with Reference => Tmp);
  714.    end Append;
  715.  
  716.    procedure Append
  717.      (Source   : in out Unbounded_String;
  718.       New_Item : in String)
  719.    is
  720.       S_Length : constant Integer := Source.Reference.all'Length;
  721.       Length   : constant Integer := S_Length + New_Item'Length;
  722.       Tmp      : String_Access;
  723.  
  724.    begin
  725.       Tmp := new String (1 .. Length);
  726.       Tmp (1 .. S_Length) := Source.Reference.all;
  727.       Tmp (S_Length + 1 .. Length) := New_Item;
  728.       Source := (Controlled with Reference => Tmp);
  729.    end Append;
  730.  
  731.    procedure Append
  732.      (Source   : in out Unbounded_String;
  733.       New_Item : in Character)
  734.    is
  735.       S_Length : constant Integer := Source.Reference.all'Length;
  736.       Length   : constant Integer := S_Length + 1;
  737.       Tmp      : String_Access;
  738.  
  739.    begin
  740.       Tmp := new String (1 .. Length);
  741.       Tmp (1 .. S_Length) := Source.Reference.all;
  742.       Tmp (S_Length + 1) := New_Item;
  743.       Source := (Controlled with Reference => Tmp);
  744.    end Append;
  745.  
  746.    ---------------
  747.    -- Translate --
  748.    ---------------
  749.  
  750.    function Translate
  751.      (Source  : Unbounded_String;
  752.       Mapping : Maps.Character_Mapping)
  753.       return    Unbounded_String
  754.    is
  755.    begin
  756.       return
  757.         To_Unbounded_String (Fixed.Translate (Source.Reference.all, Mapping));
  758.    end Translate;
  759.  
  760.    procedure Translate
  761.      (Source  : in out Unbounded_String;
  762.       Mapping : Maps.Character_Mapping)
  763.    is
  764.    begin
  765.       Fixed.Translate (Source.Reference.all, Mapping);
  766.    end Translate;
  767.  
  768.    function Translate
  769.      (Source  : in Unbounded_String;
  770.       Mapping : in Maps.Character_Mapping_Function)
  771.       return    Unbounded_String
  772.    is
  773.    begin
  774.       return
  775.         To_Unbounded_String (Fixed.Translate (Source.Reference.all, Mapping));
  776.    end Translate;
  777.  
  778.    procedure Translate
  779.      (Source  : in out Unbounded_String;
  780.       Mapping : in Maps.Character_Mapping_Function)
  781.    is
  782.    begin
  783.       Fixed.Translate (Source.Reference.all, Mapping);
  784.    end Translate;
  785.  
  786.    ----------
  787.    -- Trim --
  788.    ----------
  789.  
  790.    function Trim
  791.      (Source : in Unbounded_String;
  792.       Side   : in Trim_End)
  793.       return   Unbounded_String
  794.    is
  795.    begin
  796.       return To_Unbounded_String (Fixed.Trim (Source.Reference.all, Side));
  797.    end Trim;
  798.  
  799.    procedure Trim
  800.      (Source : in out Unbounded_String;
  801.       Side   : in Trim_End)
  802.    is
  803.    begin
  804.       Source := Trim (Source, Side);
  805.    end Trim;
  806.  
  807.    function Trim
  808.      (Source : in Unbounded_String;
  809.       Left   : in Maps.Character_Set;
  810.       Right  : in Maps.Character_Set)
  811.       return   Unbounded_String
  812.    is
  813.    begin
  814.       return
  815.         To_Unbounded_String (Fixed.Trim (Source.Reference.all, Left, Right));
  816.    end Trim;
  817.  
  818.    procedure Trim
  819.      (Source : in out Unbounded_String;
  820.       Left   : in Maps.Character_Set;
  821.       Right  : in Maps.Character_Set)
  822.    is
  823.    begin
  824.       Source := Trim (Source, Left, Right);
  825.    end Trim;
  826.  
  827. end Ada.Strings.Unbounded;
  828.